(function($) {
	
	$.controller.profile = {
			init: function(actionVars){
				console.log("Iniciado!");
			},
			profileId: null,
			index: function(actionVars) {
				if(actionVars.id ==  null)
					this.load(actionVars);
				
			},
			loadProfile: function(actionVars){
				this.load(actionVars);
			},
			load: function (actionVars) {

				$.wixet.actualPage = "";
					
					if(actionVars.id != $.wixet.user.id && actionVars.id != null){
						$.getJSON("core/user/index/id/"+actionVars.id,function(data){
							if(data.error == true){
								location.href="#search/index/id/"+actionVars.id;
							}else{
								$("#columnCenter").prepend('<div id="profileActions" class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"><div class="portlet-content">'+
							'<p align="center" style="margin: 10px;">'+
							'	<a class="dialog_link ui-state-default ui-corner-all" href="#album/loadAlbum/id/'+data.main_album_id+'"><span class="ui-icon ui-icon-image"></span>Fotos</a>'+
							'	<a class="dialog_link ui-state-default ui-corner-all" id="sendPrivateMessage" href="javascript:void(0)"><span class="ui-icon ui-icon-mail-closed"></span>Mensaje privado</a>'+
							'	<a class="dialog_link ui-state-default ui-corner-all" href="javascript:void(0)"><span class="ui-icon ui-icon-person"></span>Eliminar amigo</a>'+
							'</p></div></div>');
								$("#sendPrivateMessage").click(function(){
									$.wixet.privateMessage(actionVars.id);
								});
							}
						});
								}else $("#profileActions").remove();
				
			}
	}
	
})(jQuery);